import EventRoute from '../EventRoute'
const routers: EventRoute[] = []

// 拖拽ai问答窗口
// 开始拖拽
routers.push(
  new EventRoute('browser-view-window-start-drag', (api) => {
    api.browserViewWindow.startDrag()
  })
)
// 移动拖拽
routers.push(
  new EventRoute('browser-view-window-move-drag', (api) => {
    api.browserViewWindow.moveDrag()
  })
)
// 结束拖拽
routers.push(
  new EventRoute('browser-view-window-stop-drag', (api) => {
    api.browserViewWindow.stopDrag()
  })
)

// 显示浏览器视图
routers.push(
  new EventRoute('show-browser-view', async (api) => {
    api.browserViewWindow.showBrowserView()
  })
)

// 隐藏浏览器视图
routers.push(
  new EventRoute('hide-browser-view', async (api) => {
    api.browserViewWindow.hideBrowserView()
  })
)

// 获取页签
routers.push(
  new EventRoute('get-browser-tabs', async (api) => {
    return api.browserViewWindow.getTabsInfo()
  })
)

// 创建新页签
routers.push(
  new EventRoute('create-browser-tab', async (api, { data }) => {
    const { url } = data || {}
    return api.browserViewWindow.createTab(url)
  })
)

// 关闭页签
routers.push(
  new EventRoute('close-browser-tab', async (api, { data }) => {
    const tabId = data
    if (!tabId) return false
    return api.browserViewWindow.closeTab(tabId)
  })
)

// 切换页签
routers.push(
  new EventRoute('switch-browser-tab', async (api, { data }) => {
    const { tabId } = data || {}
    if (!tabId) return false
    return api.browserViewWindow.setActiveTab(tabId)
  })
)

// 导航到URL
routers.push(
  new EventRoute('navigate-browser-tab', async (api, { data }) => {
    const { tabId, url } = data || {}
    if (!tabId || !url) return false
    return api.browserViewWindow.navigateTo(tabId, url)
  })
)

// 页面前进
routers.push(
  new EventRoute('browser-tab-forward', async (api, { data }) => {
    const { tabId } = data || {}
    if (!tabId) return false
    return api.browserViewWindow.goForward(tabId)
  })
)

// 页面后退
routers.push(
  new EventRoute('browser-tab-back', async (api, { data }) => {
    const { tabId } = data || {}
    if (!tabId) return false
    return api.browserViewWindow.goBack(tabId)
  })
)

// 刷新页面
routers.push(
  new EventRoute('browser-tab-reload', async (api, { data }) => {
    const { tabId } = data || {}
    if (!tabId) return false
    return api.browserViewWindow.reload(tabId)
  })
)

// 创建设置页签
routers.push(
  new EventRoute('create-setting-tab', async (api) => {
    return api.browserViewWindow.createSettingTab()
  })
)

export default routers
